package com.hmdp.ProxyTest;

import java.lang.reflect.Proxy;

public class test {
    public static void main(String[] args) throws ClassNotFoundException {

        MyClac myClac = new MyClac();

        ClacInterface proxyClac = (ClacInterface) Proxy.newProxyInstance(
                myClac.getClass().getClassLoader(),
                myClac.getClass().getInterfaces(),
                (a, b, c) -> {
                    System.out.println("我代理了myClac对象");
                    return b.invoke(myClac, c);
                });

        int add = proxyClac.add(1, 3);

    }
}
